IF OBJECT_ID('dbo.fnRemoveTime') IS NOT NULL
BEGIN
    DROP FUNCTION dbo.fnRemoveTime
    IF OBJECT_ID('dbo.fnRemoveTime') IS NOT NULL
        PRINT '<<< FAILED DROPPING FUNCTION dbo.fnRemoveTime >>>'
    ELSE
        PRINT '<<< DROPPED FUNCTION dbo.fnRemoveTime >>>'
END
go

-- =======================================================================
-- Function Name: dbo.fnRemoveTime()
--
-- Author:      Kevin Cashman, Parallax Consulting LLC
--
-- Create date: 10/18/2007
--
-- Description: Removes Time Component from a DATETIME variable.
--
-- Parameters:  @DateWithTime = DATETIME
--              
-- Returns:     DATETIME 
--
-- SampleCall:
-- SELECT @date = fnRemoveTime ( @DateWithTime )
--
--------------------------------------------------------------------------
-- Date        Initials  Modification
--------------------------------------------------------------------------
-- 10/18/07     KC        Created
-- =======================================================================
CREATE FUNCTION dbo.fnRemoveTime(
     @DateWithTime DATETIME
)
     RETURNS DATETIME
AS
BEGIN
     RETURN CONVERT(DATETIME,CONVERT(VARCHAR(12),@DateWithTime))

END
go
IF OBJECT_ID('dbo.fnRemoveTime') IS NOT NULL
    PRINT '<<< CREATED FUNCTION dbo.fnRemoveTime >>>'
ELSE
    PRINT '<<< FAILED CREATING FUNCTION dbo.fnRemoveTime >>>'
go
